Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Gradle 8.5 (and OpenSearch 2.11.1 baseline) #28

Merged
merged 2 commits into from
Feb 1, 2024

Conversation

reta
Copy link

@reta reta commented Jan 25, 2024

Description

Update to Gradle 8.5 (and OpenSearch 2.11.1 baseline)

Issues Resolved

Part of opensearch-project/OpenSearch#10334

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@macohen
Copy link
Collaborator

macohen commented Jan 30, 2024

@noCharger and @jngz-es, would you be able to add your reviews to this PR as well.

Copy link
Collaborator

@macohen macohen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR is a master class in many (maybe all) of the refactorings done from 2.8 to 2.11. Would it be worth a blog post or some documentation to help anyone who has been stuck (like I was) upgrading a plugin through all of these changes?

I'd like to see if @noCharger, @mkhludnev, and @jngz-es would like to take a look at this before approval.

gradlew Show resolved Hide resolved
@@ -233,7 +233,7 @@ public Query doToQuery(LtrQueryContext context, FeatureSet featureSet, Map<Strin
Script script = new Script(this.script.getType(), this.script.getLang(),
this.script.getIdOrCode(), this.script.getOptions(), nparams);
ScoreScript.Factory factoryFactory = context.getQueryShardContext().compile(script, ScoreScript.CONTEXT);
ScoreScript.LeafFactory leafFactory = factoryFactory.newFactory(nparams, context.getQueryShardContext().lookup());
ScoreScript.LeafFactory leafFactory = factoryFactory.newFactory(nparams, context.getQueryShardContext().lookup(), context.getQueryShardContext().searcher());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is more about the newFactory function, than this review; does it make sense that we're now asking for two parameters from the same context.getQueryShardContext()? Could this parameter list continue to grow?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is more about the newFactory function, than this review; does it make sense that we're now asking for two parameters from the same context.getQueryShardContext()?

The factory does not know about QueryShardContext, it only needs lookup and searcher that could be provided by the context.

@@ -111,7 +110,7 @@ public StoredFeature(String name, List<String> params, String templateLanguage,
}

public StoredFeature(String name, List<String> params, String templateLanguage, XContentBuilder template) {
this(name, params, templateLanguage, Strings.toString(Objects.requireNonNull(template)), false);
this(name, params, templateLanguage, Objects.requireNonNull(template).toString(), false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh. this is much more standardized than the hackery I was working on previously. nice!

@@ -134,7 +133,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
} else {
builder.field(TEMPLATE.getPreferredName());
// it's ok to use NamedXContentRegistry.EMPTY because we don't really parse we copy the structure...
XContentParser parser = XContentFactory.xContent(template).createParser(NamedXContentRegistry.EMPTY,
XContentParser parser = MediaTypeRegistry.xContent(template).xContent().createParser(NamedXContentRegistry.EMPTY,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also seems redundant (based on method names) and nests too deeply. Is there another way to not call a method called xContent twice (looking for readability). otherwise, is this something we should think about updating in core?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the core is still in the middle of changes related to XContent, I think this is the way API is structured at the moment (but please feel free to suggest the other way of I am missing something)

@@ -219,14 +218,16 @@ public Query doToQuery(LtrQueryContext context, FeatureSet set, Map<String, Obje

private XContentParser createParser(Object source, NamedXContentRegistry registry) throws IOException {
if (source instanceof String) {
return XContentFactory.xContent((String) source).createParser(registry, LoggingDeprecationHandler.INSTANCE, (String) source);
return MediaTypeRegistry.xContent((String) source).xContent()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this xContent().xContent() call is really bugging me, but I definitely don't have another suggestion.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole MediaTypeRegistry.xContent is deprecated (with the goal to not "guess" the content type)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. so this is evolving. Are there other issues open in core or explanation of these deprecated methods that can be linked here so we can plan upgrades better?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@jngz-es jngz-es left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
@macohen macohen merged commit e2dbc7f into opensearch-project:main Feb 1, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants